package com.ptu.spzx.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ptu.spzx.domain.Stu.StuMessage;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author YT
 * @since 2024-01-28
 */
@Mapper
public interface StuMessageMapper extends BaseMapper<StuMessage> {
    @Select("select notice_id from stu_message where stu_id = #{stuId}")
    List<Integer> queryNoticeIdsByStuId(Long stuId);
    @Delete("delete from stu_message where notice_id = #{noticeId}")
    void deleteByNoticeId(Long noticeId);
    @Update("update stu_message set is_read = 1 where id = #{id}")
    void updateReadTrue(Long id);
    @Select("select count(*) from stu_message where notice_id = #{noticeId}")
    Long countByNoticeId(Long noticeId);
    @Select("select count(*) from stu_message where notice_id = #{noticeId} and is_read = 1")
    Long countIsRead(Long noticeId);
    @Select("select id from stu_message where stu_id = #{stuId} and notice_id = #{noticeId}")
    Long checkNotice(Long stuId, Long noticeId);

    @Select("SELECT notice_id from stu_message where stu_id = #{stuId}")
    List<Long> selectByStuId(String stuId);
}
